﻿using DotNetty.Buffers;
using QQ.Client;
using QQ.Codecs;
using static QQ.Codecs.DotNettyByteBufferExtensions.LengthType;

namespace QQ.Packet.Request.TLV
{
    public class TLV0x511 : IRequest
    {
        private readonly QQDeviceConfig config;
        public TLV0x511(QQDeviceConfig config)
        {
            this.config = config;
        }
        public IByteBuffer Serialize()
        {
            IByteBuffer ret = Unpooled.Buffer().WriteShort(config.domains.Length);
            foreach (var item in config.domains)
                ret.WriteByte(1).
                    WriteBytesWithLength(item.ToByteBuffer(), SHORT);
            return ret;
        }
    }
}